package com.alks.entity.data.enums.biocontrol;

import lombok.Getter;

/**
 * @author MS
 * @since 2024/8/13上午11:25
 */
@Getter
public enum CollectTypeEnum {
    COLLECT_IN( "缴库","O"),
    COLLECT_OUT( "发货","I");


    private final String typeCode;
    private final String typeName;

    CollectTypeEnum(String typeName, String typeCode) {
        this.typeName = typeName;
        this.typeCode = typeCode;
    }

    /**
     * 根据类型编码获取类型名称
     * @param typeCode 类型
     * @return 类型名称
     */
    public static String getTypeNameByCode(String typeCode) {
        for (CollectTypeEnum collectType : CollectTypeEnum.values()) {
            if (collectType.getTypeCode().equals(typeCode)) {
                return collectType.getTypeName();
            }
        }
        return null;
    }

    /**
     * 根据类型名称获取类型编码
     * @param typeName 类型
     * @return 名称
     */
    public static String getTypeCodeByName(String typeName) {
        for (CollectTypeEnum collectType : CollectTypeEnum.values()) {
            if (collectType.getTypeName().equals(typeName)) {
                return collectType.getTypeCode();
            }
        }
        return null;
    }

}
